import { _decorator, Component, Node } from 'cc';
import AbstractComponent from '../../base/AbstractComponent';
import { RichText } from 'cc';
import UtilTool from '../../tools/UtilTool';
import { App } from '../../App';
import { Label } from 'cc';
const { ccclass, property } = _decorator;

// 一级标题
const ONE_LEVEL_TITLE = "<outline color=#3A230A width=4><color=#FEBB2A><size=48>%s</></></>"
// 二级标题
const TWO_LEVEL_TITLE = "<color=#444032><size=36>%s</></>"

/**
 * 多人对战和四轮台球规则
 */
@ccclass('MultiRule')
export class MultiRule extends AbstractComponent {

    @property(RichText)
    rt_text : RichText = null;

    @property(Label)
    label_title : Label = null;

    gameType = 0; // [0]多人模式 [1]四球开伦 [2]血流模式

    start() {

        let formatStr = ""
        if (this.gameType == 1 || this.gameType == 2) {
            formatStr = TWO_LEVEL_TITLE
        }
        for(let i=0; i<3; i++) {
            formatStr += ONE_LEVEL_TITLE
            formatStr += TWO_LEVEL_TITLE
        }

        if(this.gameType == 0) {
            this.rt_text.string = UtilTool.formatStr(formatStr, 
                App.language.getLanguageLab(2014), "\n\n" + App.language.getLanguageLab(2015) + "\n\n",
                App.language.getLanguageLab(2016), "\n\n" + App.language.getLanguageLab(2017) + "\n\n",
                App.language.getLanguageLab(2018), "\n\n" + App.language.getLanguageLab(2019) + "\n\n",
            )
            this.label_title.string = App.language.getLanguageLab(2013)
        } else if (this.gameType == 1) {
            this.rt_text.string = UtilTool.formatStr(formatStr, 
                App.language.getLanguageLab(2065) + "\n\n",
                App.language.getLanguageLab(2014), "\n\n" + App.language.getLanguageLab(2021) + "\n\n",
                App.language.getLanguageLab(2016), "\n\n" + App.language.getLanguageLab(2022) + "\n\n",
                App.language.getLanguageLab(2018), "\n\n" + App.language.getLanguageLab(2023) + "\n\n",
            )
            this.label_title.string = App.language.getLanguageLab(2020)
        } else if (this.gameType == 2) {
            this.rt_text.string = UtilTool.formatStr(formatStr, 
                App.language.getLanguageLab(2066)["2"] + "\n\n",
                App.language.getLanguageLab(2066)["3"], "\n\n" + App.language.getLanguageLab(2066)["4"] + "\n\n",
                App.language.getLanguageLab(2066)["5"], "\n\n" + App.language.getLanguageLab(2066)["6"] + "\n\n",
                App.language.getLanguageLab(2066)["7"], "\n\n" + App.language.getLanguageLab(2066)["8"] + "\n\n",
            )
            this.label_title.string = App.language.getLanguageLab(2066)["1"]
        }

    }
    
    setGameType(gameType) {
        this.gameType = gameType;
    }

    onBtnClose() {
        this.close()
    }

}

